import React, { Component } from 'react'
interface IProps{
    history:any
}
interface IState{
    userName:string,
    passWord:string
}
export class Login extends Component<IProps,IState> {
    constructor(props:any){
        super(props)
        this.state={
            userName:'',
            passWord:'',
        }
    }
    getname=(e:any)=>{
        this.setState({
            userName:e.target.value
        })
    } 
    getpass=(e:any)=>{
        this.setState({
           passWord:e.target.value
        })
    }
    login=()=>{
        let {userName,passWord} = this.state
        // console.log(userName,passWord);
        this.props.history.push('/home')
    }
    render() {
         let {userName,passWord} = this.state
        return (
            <div className="login">
                <ul>
                    <li><input type="text" placeholder="请输入用户名" value={userName} onChange={(e)=>{this.getname(e)}}/></li>
                    <li><input type="text" placeholder="请输入密码" value={passWord} onChange={(e)=>{this.getpass(e)}}/></li>
                    <li><button onClick={()=>{this.login()}}>登录</button></li>
                    <li><a >忘记密码</a><a >新用户注册</a></li>
                </ul>
            </div>
        )
    }
}

export default Login
